home *** CD-ROM | disk | FTP | other *** search
- /*
- *--- Main.cp -------------------------------------------------
- * Copyright (c) 1995 Adobe Systems, Inc. All rights reserved.
- *
- * Copy this file to use as the starting point for your
- * plug-in code using the PageMaker Class Library.
- *
- * You then need to edit two lines in this file, a #include
- * statement to specify your plug-in class name, and a
- * statement in the try{ } block in main() to create an
- * instance of your plug-in class.
- *
- * See the comments below for more information about how
- * to modify this file. You may also wish to refer to
- * the file PluginMain.c in the "Main RAG1" folder to
- * understand how this main() module will be called when
- * your plug-in is invoked by PageMaker.
- *-------------------------------------------------------------
- */
-
- #include "PMPlugin.h"
-
- #ifdef MACINTOSH
- #include <exception.h>
- #else
- #include <eh.h>
- #endif //MACINTOSH
-
- #if __MWERKS__ && __MC68K__
- #include <A4Stuff.h>
- #include <SetupA4.h>
- #endif
-
- #ifdef WINDOWS
- #include <Windows.h>
- #endif
-
- #include "FramePlugin.h" // Add your plug-in class' .h file here.
- // It should be a subclass of PPluginCall
-
- /* ---------------- Definitions ---------------- */
- #define SUCCESS 1
- #define FAILURE 0
- #define STAYINMEMORY -1
-
- /* ---------------- PageMaker (New)SDK include files ---------------- */
- #include "CIInterfaceManager.h"
- #include "PMEvent.h"
-
- #include "PMEventRec.h"
- #include "CIBasic.h"
- #include "PMInterfaceIDs.h"
- #include "CICommandsAndQueries.h"
- #include "CIObjectAccess.h"
-
- //--- Global variables ----------------------------------------
- sPMParamBlockPtr gPB = NULL; // Stores the current executing param block
- PMMessage * gPMMessage = NULL;
-
- #ifdef WINDOWS
- PMHandle hDllInstance;
- #endif //WINDOWS
-
-
- //--- Forward declarations ------------------------------------
- #ifdef powerc
- #pragma export on
- #endif
- PMXErr main(PMMessage *pMsg);
- #ifdef powerc
- #pragma export off
- #endif
-
- #ifdef WINDOWS
- BOOL WINAPI DllMain(HINSTANCE hInstance, ULONG ul_reason, LPVOID lpvReserved);
- #endif
-
- void NiceUnexpected();
-
- PMXErr main(PMMessage *pMsg)
- {
- #if __MWERKS__ && __MC68K__
- long oldA4 = SetCurrentA4();
- RememberA4();
- #endif
-
- CIInterfaceManager *pIntfMgr = pMsg->pInterfaceMgr;
- CICommandQuery *pCmdQry = (CICommandQuery *)NULL;
-
- pIntfMgr->AcquirePMInterface(PMIID_CMDQRY, (LPVOID *)&pCmdQry);
-
- pCmdQry->Retrieve(&gPB);
-
- gPMMessage = pMsg;
-
- PMErr rc = CQ_SUCCESS;
-
- set_unexpected(NiceUnexpected);
-
- try
- {
- FramePlugin theCall;
- theCall.Dispatch(); // dispatch the call to your plug-in object
- rc = CQ_SUCCESS;
- }
- catch (PMErr err)
- {
- rc = err;
- }
- catch (...)
- {
- rc = CQ_FAILURE; // something weird goin' if we get here...
- }
-
-
- pIntfMgr->ReleasePMInterface( (LPVOID *)pCmdQry);
-
- #if __MWERKS__ && __MC68K__
- SetA4(oldA4);
- #endif
-
- return CQ_FAILURE;
- }
-
- /*
- *--- NiceUnexpected ------------------------------------------
- * The default unexpected() exception handler calls terminate.
- * This is not very friendly behavior for a plug-in, so this
- * handler just throws a CQ_FAILURE.
- *
- * Note that the routines in the PageMaker Class Library
- * should never throw an unexpected exception, so this is
- * mostly to safeguard against exception handling errors that
- * may be introduced in your code or other class libraries
- * you use in your plug-in.
- *-------------------------------------------------------------
- */
- void NiceUnexpected()
- {
- throw (PMErr)CQ_FAILURE;
- }
-
- // end of Main.cp
-
- #ifdef WINDOWS
- BOOL WINAPI DllMain(HINSTANCE hInstance, ULONG ul_reason, LPVOID lpvReserved)
- {
- hDllInstance = hInstance; /* save the Instance in a global var */
-
- switch(ul_reason)
- {
- case DLL_PROCESS_ATTACH:
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
- #endif //WINDOWS